package com.my.attendance.controller;

import com.my.attendance.service.ChaxunList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/pizhun")
public class PizhunServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("utf-8");
            resp.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");
            PrintWriter pw = resp.getWriter();

            ChaxunList chaxunList = new ChaxunList();
            String id = req.getParameter("id");
            System.out.println("批准的员工编号为："+id);
            int i =chaxunList.getpizhun(id);
            System.out.println("pizhunservlet收到的i："+i);
            if (i>=1){
                pw.write("已批准！");
//                req.getRequestDispatcher("/jsp/admin/leave_yeslist.jsp").forward(req,resp);
            }else {
                pw.write("批准失败，权限不够！");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
